package com.kpf.springcloud.service;

import com.kpf.springcloud.pojo.KpfTopic;
import com.kpf.springcloud.pojo.PageResult;
import com.kpf.springcloud.common.ResultJson;
import com.kpf.springcloud.pojo.KpfUser;
import com.kpf.springcloud.vo.KpfTopicLikeAndCollectStatusVO;
import com.kpf.springcloud.vo.KpfUserTopicListVO;
import com.kpf.springcloud.vo.PayResultVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * feign调用user的接口层
 *
 * @author shiwen
 * @date 2021/2/16
 */

@Component
@FeignClient(value = "KPF-PROVIDER-8001")   // 这一步就是去找服务提供者
public interface FeignClientUserServer {

    /**
     * 获取所有用户信息
     */
    @GetMapping("/user/queryAll")
    ResultJson<List<KpfUser>> queryAll();

    @GetMapping("/user/queryAllMp")
    ResultJson<List<KpfUser>> queryAll_mp();

    /**
     * 注册新用户
     */
    @PostMapping("/user/registerUser")
    ResultJson<Boolean> registerUser(@RequestParam(value = "age") Long age,
                                     @RequestParam(value = "phone") String phone,
                                     @RequestParam(value = "address") String address,
                                     @RequestParam(value = "username") String username,
                                     @RequestParam(value = "password") String password);

    /**
     * 登录接口
     *
     * @param phone
     * @param password
     * @return
     */
    @GetMapping("/user/login")
    ResultJson<KpfUser> login(@RequestParam(value = "phone") String phone, @RequestParam(value = "password") String password);

    /**
     * 修改个人资料
     */
    @PostMapping("/user/modifySelfInfo")
    ResultJson<Boolean> modifySelfInfo(@RequestParam(value = "headimg") String headimg,
                                       @RequestParam(value = "username") String username,
                                       @RequestParam(value = "phone") String phone,
                                       @RequestParam(value = "password") String password,
                                       @RequestParam(value = "address") String address);

    /**
     * 根据userId创建token
     *
     * @param userId
     * @param roleType
     */
    @PostMapping("/token/createToken")
    ResultJson<Boolean> createToken(@RequestParam(value = "userId") int userId, @RequestParam(value = "roleType") int roleType);

    /**
     * 校验token, 从上下文中获取userId进行校验
     */
    @GetMapping("/token/verifyToken")
    ResultJson<String> verifyToken();

    /**
     * 获取帖子列表 - 分页
     *
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/topic/getTopicList")
    ResultJson<PageResult> getTopicList(@RequestParam(value = "pageNum") int pageNum,
                                        @RequestParam(value = "pageSize") int pageSize,
                                        @RequestParam(value = "title") String title);

    /**
     * 根据id获取对象
     */
    @GetMapping("/topic/getById")
    ResultJson<KpfTopic> getById();

    /**
     * 设置topicId
     *
     * @param topicId
     * @return
     */
    @PostMapping("/topic/setTopicId")
    ResultJson setTopicId(@RequestParam(value = "topicId") int topicId);

    /**
     * 发帖接口
     *
     * @param title
     * @param content
     * @param topicMsg
     * @return
     */
    @PostMapping("/topic/editTopic")
    ResultJson editTopic(@RequestParam(value = "title") String title,
                         @RequestParam(value = "content") String content,
                         @RequestParam(value = "topicMsg") String topicMsg);

    /**
     * 点赞帖子 - 需要登陆
     *
     * @param topicId
     * @param status
     * @return
     */
    @PostMapping("/like/likeTopic")
    ResultJson likeTopic(@RequestParam(value = "topicId") int topicId, @RequestParam(value = "status") int status);

    /**
     * 收藏帖子
     *
     * @param topicId
     * @param collectStatus
     * @return
     */
    @PostMapping("/collect/collectTopic")
    ResultJson collectTopic(@RequestParam(value = "topicId") int topicId,  @RequestParam(value = "collectStatus") int collectStatus);

    /**
     * 根据帖子id和账号id获取点赞和收藏的状态
     *
     * @param topicId
     * @return
     */
    @GetMapping("/topic/getAllStatusByTopicId")
    ResultJson<KpfTopicLikeAndCollectStatusVO> getAllStatusByTopicId(@RequestParam(value = "topicId") int topicId);

    /**
     * 获取已登录的用户
     */
    @GetMapping("/user/getLoginUserById")
    ResultJson<KpfUser> getLoginUserById();

    /**
     * 生成native二维码支付的接口
     *
     * @param totalFee
     * @param body
     * @return
     */
    @PostMapping("/pay/createNative")
    ResultJson<PayResultVO> createNative(@RequestParam("totalFee") String totalFee,
                                         @RequestParam("body") String body);

    /**
     * 查询订单支付状态, 支付成功后可以回调这个接口查询订单状态
     *
     * @param outTradeNo 订单号
     * @return 支付状态
     */
    @GetMapping("/pay/queryOrder")
    ResultJson<String> queryOrder(@RequestParam("outTradeNo") String outTradeNo);

    /**
     * 获取登录用户的收藏帖子列表内容
     */
    @GetMapping("/collect/getCollectListByUserId")
    ResultJson<List<KpfTopic>> getCollectListByUserId();

    /**
     * 评论帖子
     *
     * @param topicId
     * @param content
     * @return
     */
    @PostMapping("/comment/commentTopic")
    ResultJson commentTopic(@RequestParam(value = "topicId") int topicId, @RequestParam(value = "content") String content);

    /**
     * 根据帖子id获取所有的评论内容 - 分页
     *
     * @param topicId
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/comment/getCommentListByTopicId")
    ResultJson<PageResult> getCommentListByTopicId(@RequestParam(value = "topicId") int topicId,
                                                   @RequestParam(value = "pageNum") int pageNum,
                                                   @RequestParam(value = "pageSize") int pageSize);

    @GetMapping("/user/getByUserId")
    ResultJson<KpfUserTopicListVO> getByUserId();

    @PostMapping("/user/setSelfUserId")
    ResultJson setSelfUserId(@RequestParam(value = "userId") int userId);

    @GetMapping("/topic/getTopicListByUserId")
    ResultJson<List<KpfTopic>> getTopicListByUserId();

    @PostMapping("/topic/deleteTopicById")
    ResultJson deleteTopicById(@RequestParam(value = "topicId") int topicId);

    @PostMapping("/comment/deleteCommentById")
    ResultJson deleteCommentById(@RequestParam(value = "commentId") int commentId);

    @GetMapping("/comment/getCommentList")
    ResultJson<PageResult> getCommentList(@RequestParam(value = "pageNum") int pageNum, @RequestParam(value = "pageSize") int pageSize);

    @GetMapping("/user/getUserList")
    ResultJson<PageResult> getUserList(@RequestParam(value = "pageNum") int pageNum, @RequestParam(value = "pageSize") int pageSize);

    @PostMapping("/user/deleteUserById")
    ResultJson deleteUserById(@RequestParam(value = "userId") int userId);

    @GetMapping("/token/loginOut")
    ResultJson loginOut();

    /**
     * 关注用户接口
     *
     * @param userId
     * @return
     */
    @PostMapping("/follow/followUser")
    ResultJson followUser(@RequestParam(value = "userId") int userId);

    @GetMapping("/follow/getFollowInfo")
    ResultJson getFollowInfo();

    @GetMapping("/follow/getFollowUserList")
    ResultJson getFollowUserList();

    @GetMapping("/follow/getFansList")
    ResultJson getFansList();

    //@GetMapping("/follow/getFansAndStatus")
    //ResultJson getFansAndStatus(@RequestParam(value = "followUserId") int followUserId);

}